package com.mediacloud.app.newsmodule.activity.microlive.x

//import android.content.Intent
//import android.view.View
//import android.widget.ImageView
//import androidx.fragment.app.Fragment
//import androidx.fragment.app.FragmentActivity
//import androidx.localbroadcastmanager.content.LocalBroadcastManager
//import androidx.recyclerview.widget.LinearLayoutManager
//import androidx.recyclerview.widget.RecyclerView
//import com.bumptech.glide.Glide
//import com.mediacloud.app.appfactory.cache.AppConfig
//import com.mediacloud.app.cloud.ijkplayersdk.video.VideoPlayer
//import com.mediacloud.app.model.news.ArticleItem
//import com.mediacloud.app.newsmodule.R
//import com.mediacloud.app.newsmodule.activity.microlive.BaseRecyclerAdapter
//import com.mediacloud.app.newsmodule.activity.microlive.ItemVideoAdapter
//import com.mediacloud.app.newsmodule.broadcast.AudioBackgroundBroad
//import com.mediacloud.app.newsmodule.fragment.imagetext.MicroImageTextDetailFragment
//import com.mediacloud.app.newsmodule.microlive.MicroLiveDetailData
//import com.mediacloud.app.newsmodule.model.VideoPlayerListenerImpl
//import com.mediacloud.app.newsmodule.service.AudioConst
//import com.mediacloud.app.newsmodule.service.AudioVodPlayService
//import com.mediacloud.app.newsmodule.utils.KillMusicUtils
//import com.mediacloud.app.reslib.enums.XKey
//import com.tencent.mmkv.MMKV
//
//class MicroVideoPlaying(activity: FragmentActivity) : BaseMicroLiveTab(activity), BaseRecyclerAdapter.ItemClickListener {
//    var microPlayer: VideoPlayer = findViewById(R.id.microPlayer)
//    var microPoster: ImageView = findViewById(R.id.microPoster)
//    var microRecyclerView: RecyclerView = findViewById(R.id.microRecyclerView)
//    var itemVideoAdapter: ItemVideoAdapter
//
//    init {
//        microPlayer.timeLabelShowHour = true
//        microPlayer.hideButtonBack()
//        itemVideoAdapter = ItemVideoAdapter(activity, microPlayer)
//        itemVideoAdapter.itemClickListener = this
//        val linearLayoutManager = LinearLayoutManager(activity)
//        linearLayoutManager.orientation = LinearLayoutManager.HORIZONTAL
//        microRecyclerView.layoutManager = linearLayoutManager
//        microRecyclerView.adapter = itemVideoAdapter
//        microRecyclerView.visibility = View.GONE
//        microPlayer.toggleFullScreenEnable(false)
//        microPlayer.setTopControlViewVisible(View.GONE)
//        microPlayer.setvideoQualityTitleViseble(View.GONE)
//        microPlayer.setOnPlayerListener(object : VideoPlayerListenerImpl() {
//            override fun onPrepared(currentMediaIndex: Int) {
//                super.onPrepared(currentMediaIndex)
//                stopAudio()
//                microPlayer.toggleFullScreenEnable(true)
//            }
//
//            override fun onResume(currentMediaIndex: Int) {
//                super.onResume(currentMediaIndex)
//                stopAudio()
//            }
//
//            override fun oncomplete(currentMediaIndex: Int) {
//                super.oncomplete(currentMediaIndex)
//
//            }
//
//        })
//    }
//
//
//    override fun setData(articleItem: ArticleItem, microLiveDetailData: MicroLiveDetailData?) {
//        microPlayer.showVideoTitleInfo(articleItem.getTitle())
//        microLiveDetailData?.data?.webview_content?.let {
//            microLiveWebViewFragment.setContent(it)
//        }
//        microLiveDetailData?.data?.meta?.livesType3?.let {
//            if (it.isNotEmpty()) {
//                if (!MMKV.defaultMMKV().decodeBool(XKey.AUTO_PLAY, false)) {
//                    microPlayer.data = 0
//                }
//                itemVideoAdapter.data.clear()
//                itemVideoAdapter.data.addAll(it)
//                itemVideoAdapter.notifyDataSetChanged()
//                if (itemVideoAdapter.itemCount >= 2) {
//                    microRecyclerView.visibility = View.VISIBLE
//                } else {
//                    microRecyclerView.visibility = View.GONE
//                }
//            }
//        }
//        var poster: String? = null
//        articleItem.cmsCustomStyle?.imgPath?.let {
//            if (it.isNotEmpty()) {
//                poster = articleItem.cmsCustomStyle.getImgPath()[0]
//            }
//        }
//        poster?.let {
//            poster =articleItem.logo
//        }
//        Glide.with(activity).load(poster).into(microPoster)
//    }
//
//    private fun stopPlay() {
//        val intent = Intent()
//        intent.putExtra(AudioConst.Action, AudioConst.ChangeLine)
//        intent.setClass(activity, AudioVodPlayService::class.java)
//        activity.startService(intent)
//    }
//
//    private fun stopAudio() {
//        stopPlay()
//        KillMusicUtils.stopAudioLive(activity)
//        val hideFloatIntent = Intent()
//        hideFloatIntent.action = AudioBackgroundBroad.HideAction
//        LocalBroadcastManager.getInstance(activity).sendBroadcast(hideFloatIntent)
//    }
//
//    override fun fragmentList(): ArrayList<Fragment> {
//        val fragmentList = java.util.ArrayList<Fragment>()
//        val fragment1 = MicroImageTextDetailFragment()
//        fragmentList.add(fragment1)
//        fragmentList.add(microLiveWebViewFragment)
//        //  fragmentList.add()
//        return fragmentList
//    }
//
//    override fun titleList(): MutableList<String> {
//        val titles: MutableList<String> = ArrayList()
//        titles.add("直播介绍")
//        //   titles.add("实时评论")
//        titles.add("图文直播")
//        return titles
//    }
//
//    override fun onItemClick(index: Int, isFromAdaptor: Boolean, adapter: BaseRecyclerAdapter<*>?) {
//
//    }
//}